<% @page_title = "多背一公斤 | #{h @group.title}"%>

<% content_for :sidebar do -%>
<div class="prepend-1">
  <h4><%= link_to "返回社区首页", groups_url %></h4>
  
  <h3 class="nt">其它讨论区的最新话题 <%= title_suffix %></h3>
    <% @other_topics.each do |topic| -%>
      <div class="otopic"><%= link_to h(topic.title), topic_url(topic.group, topic), :class => 'title' %>
        <span class="meta"> ... <%= link_to topic.user.login, user_url(topic.user) %> 写于 <%= link_to "[#{topic.group.title}]", group_url(topic.group) %></span>
      </div>
    <% end -%>
</div>  
<% end -%>

<h3><%= h @group.title %></h3>
<div class="prepend-1"><span class="tip">管理员：</span><%= @moderators.collect {|m| link_to m.login, user_url(m)}.join(", ") %></div>
<div class="bulletin">
	<%= @group.content_html %>

	<% if @group.editable_by?(current_user) -%>
	<p class="right">
		<%= link_to "修改小组介绍", edit_group_url(@group.id) %> | 
		<%= link_to "添加管理员", invite_moderator_group_url(@group.id) %>
	</p>
	<% end -%>
</div>
<div class="span-13"><h3 class="nt">全部的话题 <%= title_suffix %></h3></div>
<div class="span-3 last">
	<h4 style="margin-top:15px;"><%= link_to "写新话题", new_topic_url(@group.id) %></h4>
</div>
<div class="clear"></div>
<table border="0" cellspacing="0" class="group">
  <% @topics.each do |topic| -%>
  <tr>
    <td class="title"><%= link_to h(topic.title), topic_url(topic.group, topic), :class => 'title' %>
      <p class="meta"><%= calc_time_to_now topic.created_at %> 由 <%= link_to topic.user.login, user_url(topic.user) %> 发表于 <%= link_to "[#{topic.group.title}]", group_url(topic.group) %></p>
    </td>
    <td class="count">
      <%= topic.posts_count > 0 ? "#{topic.posts_count}回复" : "没有回复" %>
    </td>
    <td class="time">
      <% unless topic.replied_at.blank? -%>
      <p class="meta"><%= link_to topic.replied_by_user.login, user_url(topic.replied_by_user) %></p>
      <%= calc_time_to_now topic.replied_at %>
      <% end -%>
    </td>
  </tr>
  <% end -%>
</table>
<%= will_paginate @topics %>
